package com.posun.edu.system.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * <p>
 * TODO<br>
 *
 * @author YL
 * @version 1.0
 * @createTime 2017/4/18 12:41
 * @ChangeLog
 */
@ConfigurationProperties(prefix = "shiro")
public class ShiroProperties {

    protected static final long MILLIS_PER_SECOND = 1000;
    protected static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND;
    protected static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE;
    public static final long DEFAULT_GLOBAL_SESSION_TIMEOUT = 30 * MILLIS_PER_MINUTE;
    public static final long DEFAULT_SESSION_VALIDATION_INTERVAL = MILLIS_PER_HOUR;
    protected static final String DEFAULT_CACHE_PREFIX = "ares_shiro_cache:";

    private static final String DEFAULT_LOGIN_URL = "/sso/login";

    private static final String DEFAULT_SUCCESS_URL = "/index";

    private static final String DEFAULT_UNAUTHORIZED_URL = "/sso/unauthorized";

    private static final String DEFAULT_COOKIE_NAME = "uid";

    private static final String DEFAULT_COOKIE_PATH = "/";

    private Long globalSessionTimeout = DEFAULT_GLOBAL_SESSION_TIMEOUT;

    private Long validationInterval = DEFAULT_SESSION_VALIDATION_INTERVAL;

    private String cookieName = DEFAULT_COOKIE_NAME;

    private String cookieDomain;

    private String cookiePath = DEFAULT_COOKIE_PATH;

    private boolean cookieHttpOnly;

    private String cacheKeyPrefix = DEFAULT_CACHE_PREFIX;

    private String loginUrl = DEFAULT_LOGIN_URL;

    private String successUrl = DEFAULT_SUCCESS_URL;

    private String unauthorizedUrl = DEFAULT_UNAUTHORIZED_URL;

    public Long getGlobalSessionTimeout() {
        return globalSessionTimeout;
    }

    public void setGlobalSessionTimeout(Long globalSessionTimeout) {
        this.globalSessionTimeout = globalSessionTimeout;
    }

    public Long getValidationInterval() {
        return validationInterval;
    }

    public void setValidationInterval(Long validationInterval) {
        this.validationInterval = validationInterval;
    }

    public String getCookieName() {
        return cookieName;
    }

    public void setCookieName(String cookieName) {
        this.cookieName = cookieName;
    }

    public String getCookieDomain() {
        return cookieDomain;
    }

    public void setCookieDomain(String cookieDomain) {
        this.cookieDomain = cookieDomain;
    }

    public String getCookiePath() {
        return cookiePath;
    }

    public void setCookiePath(String cookiePath) {
        this.cookiePath = cookiePath;
    }

    public boolean isCookieHttpOnly() {
        return cookieHttpOnly;
    }

    public void setCookieHttpOnly(boolean cookieHttpOnly) {
        this.cookieHttpOnly = cookieHttpOnly;
    }

    public String getCacheKeyPrefix() {
        return cacheKeyPrefix;
    }

    public void setCacheKeyPrefix(String cacheKeyPrefix) {
        this.cacheKeyPrefix = cacheKeyPrefix;
    }

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    public String getSuccessUrl() {
        return successUrl;
    }

    public void setSuccessUrl(String successUrl) {
        this.successUrl = successUrl;
    }

    public String getUnauthorizedUrl() {
        return unauthorizedUrl;
    }

    public void setUnauthorizedUrl(String unauthorizedUrl) {
        this.unauthorizedUrl = unauthorizedUrl;
    }
}
